﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace huaguwang.virtualWeb.uc.book
{
    public partial class book_tabs : System.Web.UI.UserControl
    {
        private int i = 0;
        public void ToPage(ref M_Page m, int classlen, int namelen, int nrlen, string classurl, string url)
        {
            m.url = url + m.url;
            m.classurl = classurl + m.classurl;
            m.nr = m.nr.Exp_RegexHTML().Exp_LeftByt(namelen);
            m.classname = m.classname.Exp_LeftByt(classlen);
            m.name = m.name.Exp_LeftByt(namelen);
            var ic = m.click.Exp_IntTryParse();
            if(ic <= 10)
            {
                ic = new Random(i).Next(100, 1000);
            }
            i++;
            m.click = ic.ToString();
            m.b1 = (ic / 5).ToString();
            m.b2 = (ic / 4).ToString();
        }
        private readonly D_T_EBook_Exp dal = new D_T_EBook_Exp();
        protected void Page_Load(object sender, EventArgs e)
        {
            var dl1 = dal.GetOrder(6, true, m =>
            {
                ToPage(ref m, 8, 30, 60, "地址１/file.aspx?id=", "地址１/file.aspx?id=");
                return m;
            });
            var dl2 = dal.GetOrder(4, false, m =>
            {
                ToPage(ref m, 8, 30, 60, "地址２/file.aspx?id=", "地址２/file.aspx?id=");
                return m;
            });
            var dl4 = dal.GetOrder(6, null, m =>
            {
                ToPage(ref m, 8, 30, 60, "地址3/file.aspx?id=", "地址3/file.aspx?id=");
                return m;
            });

            this.Repeater1.DataSource = dl1;
            this.Repeater2.DataSource = dl2;
            this.Repeater4.DataSource = dl4;

            this.Repeater1.DataBind();
            this.Repeater2.DataBind();
            this.Repeater4.DataBind();
        }
    }
}